<!--
 * @Author: fisher
 * @Date: 2023-08-01 18:00:48
 * @LastEditTime: 2024-01-10 10:01:45
 * @LastEditors: fisher
 * @Description: 
 * @FilePath: \front-end-template\src\modules\DataManage\templates\components\whaleHouseDialog.vue
-->
<template>
  <div class="mask">
    <div class="content">
      <div class="header">
        <span>新增仓库</span>
        <img
          src="@/assets/img/dataManagement/close.webp"
          alt="close"
          @click="close"
        >
      </div>
      <div class="form">
        <div class="form_item">
          <span>
            <strong style="color: red">*</strong>
            仓库名称：
          </span>
          <input
            v-model="warehouseName"
            placeholder="请输入仓库名称"
            type="text"
          >
        </div>
        <div class="form_item">
          <span>仓库描述：</span>
          <textarea
            v-model="description"
            placeholder="请输入仓库描述"
          />
        </div>
        <div class="form_submit">
          <div
            class="btn"
            @click="cancel"
          >
            取消
          </div>
          <div
            class="btn btn_prime"
            @click="submit"
          >
            提交
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { addWarehouse } from '../api.js'
export default {
  components: {},
  data() {
    return {
      warehouseName: '',
      description: ''
    }
  },
  computed: {},
  mounted() {},
  destroyed() {},
  methods: {
    handleFormData() {
      const checkWarehouseName = this.warehouseName.trim()
      if (checkWarehouseName == '') {
        this.$notify({
          title: '警告',
          message: '仓库名不能为空！',
          type: 'warning'
        })
        return false
      } else {
        return {
          description: this.description,
          warehouseName: checkWarehouseName
        }
      }
    },
    submit() {
      const data = this.handleFormData()
      if (data) {
        addWarehouse(data)
          .then((res) => {
            if (res.status)
              this.$message({
                message: '添加成功！',
                type: 'success'
              })
          })
          .finally(() => {
            this.$parent.getData()
            this.close()
          })
      }

      //
    },
    cancel() {
      this.close()
    },
    close() {
      this.$parent.whaleHouseVisible = false
    }
  }
}
</script>

<style lang="scss" scoped>
.mask {
  width: 100%;
  height: 100%;
  background: rgba($color: #00152a, $alpha: 0.5);
  .content {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);

    width: 720px;
    height: 420px;
    background: #fff;
    box-shadow: 0px 12px 48px 16px rgba(0, 0, 0, 0.03), 0px 9px 28px 0px rgba(0, 0, 0, 0.05),
      0px 6px 16px -8px rgba(0, 0, 0, 0.08);
    .header {
      height: 40px;
      border-bottom: 1px solid rgba(0, 0, 0, 0.06);
      display: flex;
      justify-content: center;
      align-items: center;
      padding: 0 24px 0 24px;
      span {
        font-size: 14px;
        font-family: MicrosoftYaHei;
        color: rgba(0, 0, 0, 0.85);
        flex: 1;
      }
      img {
        width: 16px;
        height: 16px;
        cursor: pointer;
      }
    }
    .form {
      margin-top: 4px;
      padding: 0 50px;
      &_item {
        display: flex;
        justify-content: center;
        align-items: flex-start;
        margin-top: 20px;
        span {
          width: 100px;
          font-size: 14px;
          font-family: MicrosoftYaHei;
          color: rgba(0, 0, 0, 0.85);
          margin-top: 8px;
          text-align: right;
        }
        input,
        textarea {
          width: 535px;
          border: 1px solid #cbd5dd;
          outline: none;
          border-radius: 5px;
          font-size: 14px;
        }
        input {
          height: 36px;
          padding: 0 10px;
        }

        textarea {
          padding: 10px;
          height: 224px;
          resize: none;
        }
        input::-webkit-input-placeholder,
        textarea::-webkit-input-placeholder {
          // 这里写placeholder的样式
          font-size: 14px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: rgba(0, 0, 0, 0.25);
        }
      }
      &_submit {
        margin-top: 20px;
        display: flex;
        justify-content: flex-end;
        gap: 10px;
        .btn {
          width: 68px;
          height: 36px;
          background: #fff;
          border-radius: 2px;
          font-size: 14px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #262626;
          display: flex;
          justify-content: center;
          align-items: center;
          border: 1px solid #cbd5dd;
          cursor: pointer;
          // 当前页面特殊间距
        }
        .btn:hover {
          opacity: 0.85;
          box-shadow: 0 0 3px 0px #ddd;
        }
        .btn_prime {
          background: #3f9eff;
          color: #fff;
        }
      }
    }
  }
}
</style>
